package com.far;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;


public class Utils {

	public static final float[] RED = {1f, 0f, 0f, 1f};
	public static final float[] GREEN = {0f, 1f, 0f, 1f};
	public static final float[] BLUE = {0f, 0f, 1f, 1f};
	public static final float[] PURPLE = {1f, 0f, 1f, 1f};
	
	public static final float DEFAULT_RED = 0.5f;
	public static final float DEFAULT_GREEN = 0.5f;
	public static final float DEFAULT_BLUE = 1f;
	public static final float DEFAULT_ALPHA = 1f;
	
	
	public static float[] mergeFloatArrays(float[] first, float[] second){
		float[] merged = new float[first.length + second.length];
		System.arraycopy(first, 0, merged, 0, first.length);
		System.arraycopy(second, 0, merged, first.length, second.length);
		System.out.print(merged);
		return merged;
	}
	
	
	/*
	 * showToast
	 * Shortcut method to enable easy Toast Messages
	 */
	public static void showToast(Context act, String text, int opt){
		Toast.makeText(act, text, (opt == 1)? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
	}
	
	public static void handleClose(final Activity cont){
		
            AlertDialog.Builder dialog = new AlertDialog.Builder(cont);
            dialog.setIcon(android.R.drawable.ic_dialog_alert);
            dialog.setTitle("Close Application");
            dialog.setMessage("Are you sure you want to Exit?");
            dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                	System.out.println(cont.getClass().getSuperclass().getSimpleName());
                	cont.finish();
                	System.runFinalizersOnExit(true);
                	System.exit(0);
                }
            });
        
            dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                }
            });
        
            dialog.show();
	}
}
